package LeedCode.IndexArray;

public class Main1 {
    public int maxProfit(int [] nums){
        int sum=0;
        for (int x: nums) sum+=x;
        int leftSum=0;
        int rigthSum=0;
        for (int i=0;i<nums.length;i++){
            leftSum+=nums[i];
            rigthSum=sum-leftSum+nums[i];
            if (leftSum==rigthSum){
                return i;
            }
        }
        return -1;
    }
}
